{include file="public/header" /}
<body>
<style>
    @media screen and (max-width: 600px){
        .layui-table-cell {
            font-size:14px;
            padding:0 5px;
            height:auto;
            overflow:visible;
            text-overflow:inherit;
            white-space:normal;
            word-break: break-all;
        }
        .layui-btn{
            margin-top: 5px;
            margin-left: 8px;
        }
        .layui-table-col-special{
            height:67px;
        }
    }
</style>
<div class="layui-fluid">
    <div class="layui-card" >
    <!-- 你的HTML代码 -->
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend>待审列表</legend>
    </fieldset>
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <li class="layui-this">待审核</li>
            <li>已审核</li>
            <li>全部</li>
        </ul>
        <!--内容容器-->
        <div class="layui-tab-content">
            <!--待审核-->
            <div class="layui-tab-item layui-show">

                <div id="examine" style="display:none">
                    <div style="width:800px">
                        <form style="width:90%;margin-left:5%;" class="layui-form layui-form-pane" lay-filter="exform" id="exform"></form>
                    </div>
                </div>
                <div class="search"  id="search" style="margin-top:1rem">
                    发起人：
                    <div class="layui-inline">
                        <input class="layui-input" name="sponsor" id="sponsor" autocomplete="off">
                    </div>
<!--                    搜索流程名：-->
<!--                    <div class="layui-inline">-->
<!--                        <input class="layui-input" name="name" id="searchname" autocomplete="off">-->
<!--                    </div>-->
                    <button class="layui-btn" id="reload" data-type="reload">搜索</button>
                </div>
                <div style="margin-top:1rem">
                <!--站点列表-->
                <table class="layui-hide" lay-filter="workflow" id="workflow"></table>
                <!--站点列表end-->
                <!--审核操作菜单-->
                <script type="text/html" id="bar">
                    <a class="layui-btn layui-btn-xs"  lay-event="examine">审核</a>
                </script>
                <!--审核操作菜单end-->
                <!--下载操作菜单-->
                <script type="text/html" id="down">
                    <a class="layui-btn layui-btn-xs"  lay-event="down">下载</a>
                </script>
                <script type="text/html" id="downs">
                    <a class="layui-btn layui-btn-xs"  lay-event="down">下载</a>
                    <a class="layui-btn layui-btn-danger layui-btn-xs"  lay-event="del">删除</a>
                </script>
                <!--下载操作菜单end-->
                </div>
            </div>
            <!--待审核end-->
            <!--已审核-->
            <div class="layui-tab-item">

                <div id="examines" style="display:none">
                    <div style="width:800px">
                        <form style="width:90%;margin-left:5%;" class="layui-form layui-form-pane" lay-filter="exforms" id="exforms"></form>
                    </div>
                </div>
                <div class="searchs"  id="searchs" style="margin-top:1rem">
                    发起人：
                    <div class="layui-inline">
                        <input class="layui-input" name="sponsors" id="sponsors" autocomplete="off">
                    </div>
<!--                    搜索流程名：-->
<!--                    <div class="layui-inline">-->
<!--                        <input class="layui-input" name="name" id="searchnames" autocomplete="off">-->
<!--                    </div>-->
                    <button class="layui-btn" id="reloads" data-type="reloads">搜索</button>
                </div>
                <div style="margin-top:1rem">
                <!--站点列表-->
                <table class="layui-hide" lay-filter="workflows" id="workflows"></table>
                <!--站点列表end-->
                <!--审核操作菜单-->
                <script type="text/html" id="bars">
                    <a class="layui-btn layui-btn-xs"  lay-event="details">详情</a>
                    <a class="layui-btn layui-btn-xs"  lay-event="process">进度</a>
                </script>
                <!--审核操作菜单end-->
                <!--下载操作菜单-->
                <script type="text/html" id="down2">
                    <a class="layui-btn layui-btn-xs"  lay-event="down">下载</a>
                </script>
                <script type="text/html" id="downs2">
                    <a class="layui-btn layui-btn-xs"  lay-event="down">下载</a>
                    <a class="layui-btn layui-btn-danger layui-btn-xs"  lay-event="del">删除</a>
                </script>
                <!--下载操作菜单end-->
                </div>
            </div>
            <!--已审核end-->
            <!--全部-->
            <div class="layui-tab-item">

                <div id="examiness" style="display:none">
                    <div style="width:800px">
                        <form style="width:90%;margin-left:5%;" class="layui-form layui-form-pane" lay-filter="exforms" id="exformss"></form>
                    </div>
                </div>
                <div class="searchs"  id="searchss" style="margin-top:1rem">
                    发起人：
                    <div class="layui-inline">
                        <input class="layui-input" name="sponsors" id="sponsorss" autocomplete="off">
                    </div>
                    <!--                    搜索流程名：-->
                    <!--                    <div class="layui-inline">-->
                    <!--                        <input class="layui-input" name="name" id="searchnames" autocomplete="off">-->
                    <!--                    </div>-->
                    <button class="layui-btn" id="reloadss" data-type="reloads">搜索</button>
                </div>
                <div style="margin-top:1rem">
                    <!--站点列表-->
                    <table class="layui-hide" lay-filter="workflows" id="workflowss"></table>
                    <!--站点列表end-->
                    <!--审核操作菜单-->
                    <script type="text/html" id="barss">
                        <a class="layui-btn layui-btn-xs"  lay-event="details">详情</a>
                        <a class="layui-btn layui-btn-xs"  lay-event="process">进度</a>
                    </script>
                    <!--审核操作菜单end-->
                    <!--下载操作菜单-->
                    <script type="text/html" id="down3">
                        <a class="layui-btn layui-btn-xs"  lay-event="down">下载</a>
                    </script>
                    <script type="text/html" id="downs3">
                        <a class="layui-btn layui-btn-xs"  lay-event="down">下载</a>
                        <a class="layui-btn layui-btn-danger layui-btn-xs"  lay-event="del">删除</a>
                    </script>
                    <!--下载操作菜单end-->
                </div>
            </div>
            <!--全部end-->
        </div>
        <!--内容容器end-->
    </div>
	</div>
</div>
<script src="__SKIN__/workflow/js/form_assembly.js" charset="utf-8"></script>
<script>
    //同步ajax请求数据转出
    var ajax = function(url,data){
        var arr = {};
        $.ajax({
            url:url,
            type:'post',
            data:data,
            dataType:"html",
            async: false,//关闭异步
            success:function(e){
                arr = eval('(' + e + ')');
            }
        });
        return arr;
    }

    function IsPC() {
        var userAgentInfo = navigator.userAgent;
        var Agents = ["Android", "iPhone",
            "SymbianOS", "Windows Phone",
            "iPad", "iPod"];
        var flag = false;
        for (var v = 0; v < Agents.length; v++) {
            if (userAgentInfo.indexOf(Agents[v]) > 0) {
                flag = true;
                break;
            }
        }
        return flag;
    }

    layui.use(['table','form','layer','upload','element'], function() {
        var table = layui.table;
        var element = layui.element;
        var flag = IsPC();
        /*******************************初始化表格  -- 待审核******************************/
        table.render({
            elem: '#workflow'
            , url: "{$url}&state=0"
            , cellMinWidth: 60 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            , toolbar: '#toolbar' //开启头部工具栏，并为其绑定左侧模板
            , cols: [[
                // {type: 'checkbox', width: '2.8%'}
                // , {field: 'id', title: 'ID', width: '4.7%', sort: true}
                {field: 'name', title: '流程名称',hide: flag}
                , {
                    field: 'sponsor', title: '发起人'}
                , {field: 'create_time', title: '创建时间', sort: true,hide: flag}
                // , {field: 'flow_id', title: '流程模版ID', width: '7.2%', sort: true,hide: flag}
                , {field: 'process_name', title: '下一审核节点', sort: true,hide: flag}
                , {field: 'peoples', title: '下一节点审核人', align: 'center', sort: true,hide: flag}
                , {
                    field: 'con_sign', title: '是否会审', templet: function (e) {
                        if (e.con_sign == 3) {
                            return '<span style="color: #0339fd;">是</span>';
                        } else {
                            return '<span style="color: #03ff06;">否</span>';
                        }
                    }
                    ,hide: flag
                }
                , {
                    field: 'audit_status', title: '审核状态',templet: function (e) {
                        if (e.audit_status == 1) {
                            return '<span style="color: #fdd303;">审核中</span>';
                        } else if (e.audit_status == 2) {
                            return '<span style="color: #03ff06;">已通过</span>';
                        } else if (e.audit_status == 3) {
                            return '<span style="color: #ff0101;">被打回</span>';
                        }
                    }
                }//minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
                , {fixed: 'right',title:'操作', toolbar: '#bar'}
            ]]
            ,id: 'workflow'  //重载ID
            ,page: true
            ,limit: 5
            ,limits:[5,10,15,20,25]
            , response: {
                statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
            }
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                };
            },
        });
        /**********************************表格重载(查询)************************************/
        var btns = {
            reload: function(){
                var sponsor = $('#sponsor');
                // var searchname = $('#searchname');

                //执行重载
                table.reload('workflow', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        sponsor: sponsor.val(),
                        // name: searchname.val(),
                    }
                }, 'data');
            }
        };
        /*******************************监听行工具事件（待处理）*********************************/
        table.on('tool(workflow)', function (obj) {
            var data = obj.data;
            if (obj.event === 'examine') {
                console.log(data);
                if(data.peoples !=''){
                    if(data.is_qualifications==0){
                        active.examine(data);
                    }else{
                        layer.msg('该节点不是由您审核');
                    }

                }else{
                    layer.msg('该流程已结束');
                }
            }
        });
        //弹窗表单
        var active = {
            examine: function (e) {
                var that = this;
                top.workflow = e;
                top.type = 'examine';

                _big = layer.open({
                    type: 2//此处以iframe举例
                    , title: '审核'
                    , area: ['817px', '600px']
                    , shade: 0.3
                    , shadeClose: true
                    , maxmin: true
                    , offset: 'auto'
                    // ,content: $("#examine")
                    , content: "{:url('workflowrovalstart/examine_workflow')}"
                    , btn: ['关闭']
                    , btn1: function (index, layero) {
                        layer.close(index);
                        return false;
                    },
                    cancel: function (layero, index) {
                        layer.closeAll();
                    },
                    end: function () {
                        table.reload('workflow');
                        table.reload('workflows');
                        table.reload('workflowss');
                    }
                });
                layer.full(_big); //窗口直接顶天立地
            }
        };
        //弹窗表单按钮控制器
        $('#extra .layui-btn').on('click', function () {
            var othis = $(this), method = othis.data('method');
            alert(othis);return;
            active[method] ? active[method].call(this, othis) : '';
        });
        $('#search .layui-btn').on('click', function () {
            btns.reload();
        });
    })
    /**************************layui实例化结束*************************/
</script>
<!--已审核-->
<script>
    //同步ajax请求数据转出

    layui.use(['table','form','layer','upload','element'], function() {
        var table = layui.table;
        var element = layui.element;
        var flag = IsPC();
        /*******************************初始化表格  -- 待审核******************************/
        table.render({
            elem: '#workflows'
            , url: "{$url}&state=1"
            , cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            , toolbar: '#toolbars' //开启头部工具栏，并为其绑定左侧模板
            , cols: [[
                // {type: 'checkbox', width: '2.8%'}
                // , {field: 'id', title: 'ID', width: '4.7%', sort: true}
                {field: 'name', title: '流程名称', hide: flag}
                , {field: 'sponsor', title: '发起人'}
                , {field: 'create_time', title: '创建时间', sort: true,hide: flag}
                // , {field: 'flow_id', title: '流程模版ID', width: '7.2%', sort: true}
                , {field: 'process_name', title: '下一审核节点', sort: true,hide: flag}
                , {field: 'peoples', title: '下一节点审核人', align: 'center', sort: true,hide: flag}
                , {
                    field: 'con_sign', title: '是否会审', templet: function (e) {
                        if (e.con_sign == 3) {
                            return '<span style="color: #0339fd;">是</span>';
                        } else {
                            return '<span style="color: #03ff06;">否</span>';
                        }
                    }
                    ,hide: flag
                }
                , {
                    field: 'audit_status', title: '审核状态', templet: function (e) {
                        if (e.audit_status == 1) {
                            return '<span style="color: #fdd303;">审核中</span>';
                        } else if (e.audit_status == 2) {
                            return '<span style="color: #03ff06;">已通过</span>';
                        } else if (e.audit_status == 3) {
                            return '<span style="color: #ff0101;">被打回</span>';
                        }
                    }
                }//minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
                , {fixed: 'right',title:'操作', toolbar: '#bars'}
            ]]
            , id: 'workflowss'  //重载ID
            , page: true
            ,limit: 5
            ,limits:[5,10,15,20,25]
            , response: {
                statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
            }
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                };
            },
        });
        /**********************************表格重载(查询)************************************/
        var btnss = {
            reload: function(){
                var sponsors = $('#sponsors');
                // var searchnames = $('#searchnames');
                //执行重载
                table.reload('workflows', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        sponsor: sponsors.val(),
                        // name: searchnames.val(),
                    }
                }, 'data');
            }
        };
        /*******************************监听行工具事件（待处理）*********************************/
        table.on('tool(workflows)', function (obj) {
            var data = obj.data;
            if (obj.event === 'details') {
                active.details(data);
            }else if(obj.event === 'process'){
                active.settimeline(data);
            }
        });
        //弹窗表单
        var active = {
            examine: function (e) {
                var that = this;
                top.workflow = e;
                top.type = 'examines';

                _big = layer.open({
                    type: 2//此处以iframe举例
                    , title: '审核'
                    , area: ['817px', '600px']
                    , shade: 0.3
                    , shadeClose: true
                    , maxmin: true
                    , offset: 'auto'
                    // ,content: $("#examine")
                    , content: "{:url('workflowrovalstart/examine_workflow')}"
                    , btn: ['关闭']
                    , btn1: function (index, layero) {
                        layer.close(index);
                        return false;
                    },
                    cancel: function (layero, index) {
                        layer.closeAll();
                    },
                    end: function () {

                        table.reload('workflow');
                        table.reload('workflows');
                        table.reload('workflowss');
                    }
                });
                layer.full(_big); //窗口直接顶天立地
            },
            settimeline: function (e) {
                top.workflow = e;
                layer.open({
                    type: 2//此处以iframe举例
                    , title: '时间轴'
                    , area: ['100%', '800px']
                    , shade: 0.3
                    , shadeClose: true
                    , maxmin: true
                    , offset: 'auto'
                    // ,content: $("#time_line")
                    , content: "{:url('workflowrovalstart/process')}"
                    , btn: ['关闭']
                    , btn1: function (index, layero) {
                        layer.close(index);
                        return false;
                    },
                    cancel: function (layero, index) {
                        layer.closeAll();
                    }
                });
            },
            details: function (e) {
                _aaa = layer.open({
                    type: 2//此处以iframe举例
                    , title: '详情'
                    , area: ['817px', '600px']
                    , shade: 0.3
                    , shadeClose: true
                    , maxmin: true
                    , offset: 'auto'
                    , content: "{$details_url}"+e.form_extend
                    , btn: ['关闭']
                    , btn1: function (index, layero) {
                        layer.close(index);
                        return false;
                    },
                    cancel: function (layero, index) {
                        layer.closeAll();
                    },
                    end: function () {
                        table.reload('workflow');
                    }
                });
                layer.full(_aaa); //窗口直接顶天立地
            },
        };
        //弹窗表单按钮控制器
        $('#extras .layui-btn').on('click', function () {
            var othis = $(this), method = othis.data('method');
            alert(othis);return;
            active[method] ? active[method].call(this, othis) : '';
        });
        $('#searchs .layui-btn').on('click', function () {
            btnss.reload();
        });
    })
    /**************************layui实例化结束*************************/
</script>
<!--全部-->
<script>
    //同步ajax请求数据转出

    layui.use(['table','form','layer','upload','element'], function() {
        var table = layui.table;
        var element = layui.element;
        var flag = IsPC();
        /*******************************初始化表格  -- 待审核******************************/
        table.render({
            elem: '#workflowss'
            , url: "{$url}&state=2"
            , cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            , toolbar: '#toolbars' //开启头部工具栏，并为其绑定左侧模板
            , cols: [[
                // {type: 'checkbox', width: '2.8%'}
                // , {field: 'id', title: 'ID', width: '4.7%', sort: true}
                {field: 'name', title: '流程名称', hide: flag}
                , {field: 'sponsor', title: '发起人'}
                , {field: 'create_time', title: '创建时间', sort: true,hide: flag}
                // , {field: 'flow_id', title: '流程模版ID', width: '7.2%', sort: true}
                , {field: 'process_name', title: '下一审核节点', sort: true,hide: flag}
                , {field: 'peoples', title: '下一节点审核人', align: 'center', sort: true,hide: flag}
                , {
                    field: 'con_sign', title: '是否会审', templet: function (e) {
                        if (e.con_sign == 3) {
                            return '<span style="color: #0339fd;">是</span>';
                        } else {
                            return '<span style="color: #03ff06;">否</span>';
                        }
                    }
                    ,hide: flag
                }
                , {
                    field: 'audit_status', title: '审核状态', templet: function (e) {
                        if (e.audit_status == 1) {
                            return '<span style="color: #fdd303;">审核中</span>';
                        } else if (e.audit_status == 2) {
                            return '<span style="color: #03ff06;">已通过</span>';
                        } else if (e.audit_status == 3) {
                            return '<span style="color: #ff0101;">被打回</span>';
                        }
                    }
                }//minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
                , {fixed: 'right',title:'操作', toolbar: '#bars'}
            ]]
            , id: 'workflowss'  //重载ID
            , page: true
            ,limit: 5
            ,limits:[5,10,15,20,25]
            , response: {
                statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
            }
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                };
            },
        });
        /**********************************表格重载(查询)************************************/
        var btnss = {
            reload: function(){
                var sponsors = $('#sponsors');
                // var searchnames = $('#searchnames');
                //执行重载
                table.reload('workflowss', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        sponsor: sponsors.val(),
                        // name: searchnames.val(),
                    }
                }, 'data');
            }
        };
        /*******************************监听行工具事件（待处理）*********************************/
        table.on('tool(workflowss)', function (obj) {
            var data = obj.data;
            if (obj.event === 'details') {
                active.details(data);
            }else if(obj.event === 'process'){
                active.settimeline(data);
            }
        });
        //弹窗表单
        var active = {
            examine: function (e) {
                var that = this;
                top.workflow = e;
                top.type = 'examines';

                _big = layer.open({
                    type: 2//此处以iframe举例
                    , title: '审核'
                    , area: ['817px', '600px']
                    , shade: 0.3
                    , shadeClose: true
                    , maxmin: true
                    , offset: 'auto'
                    // ,content: $("#examine")
                    , content: "{:url('workflowrovalstart/examine_workflow')}"
                    , btn: ['关闭']
                    , btn1: function (index, layero) {
                        layer.close(index);
                        return false;
                    },
                    cancel: function (layero, index) {
                        layer.closeAll();
                    },
                    end: function () {
                        table.reload('workflow');
                        table.reload('workflows');
                        table.reload('workflowss');
                    }
                });
                layer.full(_big); //窗口直接顶天立地
            },
            settimeline: function (e) {
                top.workflow = e;
                layer.open({
                    type: 2//此处以iframe举例
                    , title: '时间轴'
                    , area: ['100%', '800px']
                    , shade: 0.3
                    , shadeClose: true
                    , maxmin: true
                    , offset: 'auto'
                    // ,content: $("#time_line")
                    , content: "{:url('workflowrovalstart/process')}"
                    , btn: ['关闭']
                    , btn1: function (index, layero) {
                        layer.close(index);
                        return false;
                    },
                    cancel: function (layero, index) {
                        layer.closeAll();
                    }
                });
            },
            details: function (e) {
                _aaa = layer.open({
                    type: 2//此处以iframe举例
                    , title: '详情'
                    , area: ['817px', '600px']
                    , shade: 0.3
                    , shadeClose: true
                    , maxmin: true
                    , offset: 'auto'
                    , content: "{$details_url}"+e.form_extend
                    , btn: ['关闭']
                    , btn1: function (index, layero) {
                        layer.close(index);
                        return false;
                    },
                    cancel: function (layero, index) {
                        layer.closeAll();
                    },
                    end: function () {
                        table.reload('workflowss');
                    }
                });
                layer.full(_aaa); //窗口直接顶天立地
            },
        };
        //弹窗表单按钮控制器
        $('#extrass .layui-btn').on('click', function () {
            var othis = $(this), method = othis.data('method');
            alert(othis);return;
            active[method] ? active[method].call(this, othis) : '';
        });
        $('#searchss .layui-btn').on('click', function () {
            btnss.reload();
        });
    })
    /**************************layui实例化结束*************************/
</script>
